<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	session.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="${basePath }">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>西普茗茶商品-退换货</title>
<meta name="renderer" content="webkit">

<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="https://cdn.bootcss.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="https://cdn.bootcss.com/Swiper/3.0.8/css/swiper.min.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css" />
<link href="assets/css/plugins.css" rel="stylesheet" type="text/css" />
<link href="assets/css/themes/light.css" rel="stylesheet" type="text/css" id="style_color" />
<link href="assets/css/custom.css" rel="stylesheet" type="text/css" />
<link href="assets/css/pages/blog.css" rel="stylesheet" type="text/css" />
<link href="css/iconfont.css" rel="stylesheet" type="text/css" />
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico" />

<script type="text/javascript">
	var isHTML5 = true;
</script>
<!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<script src="js/excanvas.min.js"></script> 
    <script type="text/javascript">
		isHTML5 = false;
	</script>
<![endif]-->

<style type="text/css">
body {
	background: #fef9f3 !important;
}
</style>
</head>
<!--/head-->
<!-- BEGIN BODY -->
<body class="page-footer-fixed">
	<!-- END HEADER -->
	<div class="clearfix "></div>
	<!-- BEGIN CONTAINER -->
	<div class="page-container">

		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content no-space" style="border-bottom: none !important;">
				<div>
					<div class="tabbable-custom nav-justified">
						<ul class="nav nav-tabs nav-justified">
							<li>
								<a href="show_could_apply_return_order_list"> 我要申请 </a>
							</li>
							<li class="active">
								<a href="show_order_return_list"> 进度查询 </a>
							</li>
						</ul>
						<div class="tab-content">
							<div class="tab-pane active">
								<c:if test="${complexOrderReturnList==null||fn:length(complexOrderReturnList)<=0 }">
									<p class="text-center margin-top-20 margin-bottom-20">没有更多退换货订单了</p>
								</c:if>
								<c:forEach items="${complexOrderReturnList }" var="co" varStatus="coStat">
									<div id="div_${co.order.orderId }" class="well well-sm margin-top-10 margin-bottom-10">
										<h5 class="text-left">
											<span><fmt:formatDate value="${co.order.orderBuyTime }" pattern="yyyy年MM月dd日" /></span>
											<c:choose>
												<c:when test="${co.orderReturn.orderReturnStatus=='申请审核中' }">
													<span class="label label-default pull-right">${co.orderReturn.orderReturnStatus }</span>
												</c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='买家退换货中' }">
													<span class="label label-primary pull-right">${co.orderReturn.orderReturnStatus }</span>
												</c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='卖家处理中' }">
													<span class="label label-info pull-right">${co.orderReturn.orderReturnStatus }</span>
												</c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='已完成' }">
													<span class="label label-success pull-right">${co.orderReturn.orderReturnStatus }</span>
												</c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='申请未通过' }">
													<span class="label label-danger pull-right">${co.orderReturn.orderReturnStatus }</span>
												</c:when>
											</c:choose>
										</h5>
										<div class="blog-page no-space">
											<div class="clearfix"></div>
											<c:set var="one_order_goods_count" value="0"></c:set>
											<c:forEach items="${co.goodsHistoryItemList}" var="goodsHistoryItem" varStatus="giStat">
												<hr style="margin-top: 5px !important; margin-bottom: 5px !important;">
												<div class="container order_detail_click_div" data-order-id="${co.order.orderId }">
													<div class="row">
														<div class="col-xs-12">
															<div class="media padding-top-5">
																<a href="item/${goodsHistoryItem.goodsHistory.goodsId }" class="pull-left">
																	<img alt="" src="${goodsHistoryItem.goodsHistory.goodsMainPic }" class="media-object">
																</a>
																<div class="media-body">
																	<h5 class="media-heading">
																		<span>${goodsHistoryItem.goodsHistory.goodsName }</span>
																	</h5>
																	<p class="margin-top-5">
																		<span class="text-light">价格：</span><span class="text-red"><strong><i class="fa fa-rmb"></i> <fmt:formatNumber value="${goodsHistoryItem.goodsHistory.goodsPrice }" type="currency"
																					pattern="#,##0.##" /></strong></span>
																	</p>
																	<p>
																		<span class="text-light">数量：</span><span class="text-red"><strong>${goodsHistoryItem.number }</strong></span>
																	</p>
																	<div class="clearfix"></div>
																</div>
															</div>
														</div>
													</div>
												</div>
												<c:set var="one_order_goods_count" value="${one_order_goods_count+goodsHistoryItem.number }"></c:set>
											</c:forEach>
										</div>
										<hr style="margin-top: 5px !important; margin-bottom: 5px !important;">
										<h5 class="text-right">
											<span>共${one_order_goods_count }件商品，合计：<span class="text-red"><strong><i class="fa fa-rmb"></i> <fmt:formatNumber value="${co.order.orderTotalPrice }" type="currency" pattern="#,##0.##" /></strong></span></span>
										</h5>
										<hr style="margin-top: 5px !important; margin-bottom: 5px !important;">
										<p class="text-right">
											<c:choose>
												<c:when test="${co.orderReturn.orderReturnStatus=='买家退换货中' }">
													<c:if test="${co.orderReturn.orderBuyerExpressCompany==null||co.orderReturn.orderBuyerExpressCompany=='' }">
														<button type="button" class="btn blue buyer_write_return_express_button border-radius-5" data-order-return-id="${co.orderReturn.orderReturnId }">填写退换货快递信息</button>
													</c:if>
													<c:if test="${co.orderReturn.orderBuyerExpressCompany!=null&&co.orderReturn.orderBuyerExpressCompany!='' }">
														<span class="label label-primary">已寄件(${co.orderReturn.orderBuyerExpressCompany }：${co.orderReturn.orderBuyerExpressNumber })</span>
													</c:if>
												</c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='卖家处理中' }">
													<c:if test="${co.orderReturn.orderSellerExpressCompany!=null&&co.orderReturn.orderSellerExpressCompany!='' }">
														<span class="label label-info">卖家已换货(${co.orderReturn.orderSellerExpressCompany }：${co.orderReturn.orderSellerExpressNumber })</span>
														<br>
														<button type="button" class="btn margin-top-5 blue buyer_receive_seller_order_return_express_button border-radius-5" data-order-return-id="${co.orderReturn.orderReturnId }">确认收货</button>
													</c:if>
												</c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='' }"></c:when>
												<c:when test="${co.orderReturn.orderReturnStatus=='' }"></c:when>
											</c:choose>

										</p>
									</div>
								</c:forEach>
							</div>
						</div>
					</div>

					<div class="text-center" style="margin-bottom: 50px;">
						<p id="dynamic_pager_demo2" data-totalPages="${page.totalPages}" data-currentIndex="${page.currentIndex}"></p>
					</div>

				</div>
			</div>
		</div>
		<!-- END CONTAINER -->
	</div>
	<!-- BEGIN FOOTER -->
	<div class="footer">
		<div class="container">
			<div class="row">
				<div class="col-xs-3 text-center">
					<a href="./" class="icon-btn">
						<!-- <i class="fa fa-home text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-logo">&#xe626;</i>
						<div class="text-gold margin-top-2">首页</div>

					</a>
				</div>
				<div class="col-xs-3 text-center">
					<a href="goods_type/get_shop_goods_type" class="icon-btn">
						<!-- <i class="fa fa-list-ul text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold con-qh-all-goods">&#xe622;</i>
						<div class="text-gold margin-top-2">类型</div>
					</a>
				</div>
				<div class="col-xs-3 text-center">
					<a href="cart" class="icon-btn">
						<!-- <i class="fa fa-shopping-cart text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-cart">&#xe61b;</i>
						<div class="text-gold margin-top-2">购物车</div>

						<span class="badge badge-important" id="shooping_cart_icon_number"></span>
					</a>
				</div>
				<div class="col-xs-3 text-center">
					<a href="item/infocenter.jsp" class="icon-btn">
						<!-- <i class="fa fa-user text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-infocenter">&#xe61d;</i>
						<div class="text-gold margin-top-2">个人中心</div>
					</a>
				</div>
			</div>
		</div>
	</div>
	<!-- END FOOTER -->

	<!-- 填写退换货快递信息开始 -->
	<!-- /.modal -->
	<div class="modal fade" id="buyer_express_info_modal" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-full" style="margin-left: 0px !important; margin-right: 0px !important;">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title text-center">填写退换货快递信息</h4>
				</div>
				<div class="modal-body" style="padding-bottom: 0px !important;">
					<input type="hidden" id="return_order_id_input">
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label>*快递公司</label>
								<input type="text" class="form-control" id="orderBuyerExpressCompany" data-regex="^\S.{0,48}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label>*快递单号</label>
								<input type="text" class="form-control" id="orderBuyerExpressNumber" data-regex="^\S.{0,48}\S$">
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn default pull-left" data-dismiss="modal">关闭</button>
					<button type="button" class="btn blue pull-right" id="buyer_express_info_submit_button">提交</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- 填写退换货快递信息结束 -->


	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/jquery-migrate/1.2.1/jquery-migrate.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="assets/plugins/jquery-bootpag/jquery.bootpag.min.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="js/app.js"></script>
	<!-- END PAGE LEVEL SCRIPTS -->

	<script>
		$(function()
		{
			// Initiat WOW JS
			if (isHTML5 == true)
			{
				new WOW().init();
			}
			App.init();

			$('#dynamic_pager_demo2').bootpag(
			{
				paginationClass : 'pagination pagination-sm',
				next : '<i class="fa fa-angle-right"></i>',
				prev : '<i class="fa fa-angle-left"></i>',
				total : $('#dynamic_pager_demo2').attr("data-totalPages"),
				page : $('#dynamic_pager_demo2').attr("data-currentIndex"),
				maxVisible : 5
			}).on('page', function(event, num)
			{
				//$("#dynamic_pager_content2").html("Page " + num + " content here"); // or some ajax content loading...

				window.location.href = "show_order_return_list?s={param.s}&i=" + num;
			});

			$(".buyer_write_return_express_button").each(function()
			{
				var obj = $(this);
				obj.click(function()
				{
					$("#return_order_id_input").val(obj.attr("data-order-return-id"));
					$("#buyer_express_info_modal").modal('show');
				});

			});

			$("#buyer_express_info_submit_button").click(function()
			{
				var orderReturnId = $("#return_order_id_input").val();
				var orderBuyerExpressCompany = $("#orderBuyerExpressCompany").val();
				var orderBuyerExpressNumber = $("#orderBuyerExpressNumber").val();

				if (orderReturnId.length <= 0 || orderBuyerExpressCompany.length <= 0 || orderBuyerExpressNumber.length <= 0)
				{
					alert("标有*的输入项都是必填项.")
					return false;
				}

				var tips = "";
				var tips_number = 1;
				$.each([ $("#orderBuyerExpressCompany"), $("#orderBuyerExpressNumber") ], function(i, n)
				{
					if (new RegExp(n.attr("data-regex")).test(n.val()) == false)
					{
						tips += tips_number++ + " . \"" + n.val() + "\" 不满足输入要求;\n";
					}
				});
				if (tips.length > 0)
				{
					alert(tips + "\n请检查一下重新输入.");
					return false;
				}

				var buyer_express_info_submit_button_html = $("#buyer_express_info_submit_button").html();
				$.ajax(
				{
					url : "${basePath}u_write_buyer_express_info_do",
					type : "POST",
					dataType : "json",
					beforeSend : function(XMLHttpRequest)
					{
						$("#buyer_express_info_submit_button").attr("disabled", "disabled");
						$("#buyer_express_info_submit_button").html("正在提交快递信息中...");
					},
					data :
					{
						'orderReturn.orderReturnId' : orderReturnId,
						'orderReturn.orderBuyerExpressCompany' : orderBuyerExpressCompany,
						'orderReturn.orderBuyerExpressNumber' : orderBuyerExpressNumber
					},
					success : function(json, textStatus)
					{
						if (json.success == true)
						{
							alert("提交信息成功");
							window.location.href = "show_order_return_list?time=" + new Date();
						}
						else
						{
							alert(json.info);
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。");
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#buyer_express_info_submit_button").removeAttr("disabled");
						$("#buyer_express_info_submit_button").html(buyer_express_info_submit_button_html);
					}
				});
			});

			//买家确认收到卖家换货包裹
			$(".buyer_receive_seller_order_return_express_button").each(function()
			{
				$(this).click(function()
				{
					if (confirm("确认已经收到货了吗?") == false)
					{
						return false;
					}
					var ids = "";
					ids = $(this).attr("data-order-return-id");
					var obj = $(this);

					obj.attr("disabled", "disabled");
					$.post("u_confirm_receive_seller_order_return_do",
					{
						"commonStr" : ids
					}, function(json)
					{
						if (json.success == true)
						{
							window.location.href = "show_order_return_list?time=" + new Date();
						}
						else
						{
							alert(json.info);
						}
					},
					//返回类型
					"json");
				});
			});

		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
</html>